import Vue from 'vue'
import Router from 'vue-router'

import index from '@/views/index'
import search from '@/views/search'
import exhibitions from '@/views/exhibitions'
import exhibitionsCreate from '@/views/exhibitions/create'
import exhibitionsId from '@/views/exhibitions/_id'
import exhibitionsIdPublish from '@/views/exhibitions/_id/publish'
import news from '@/views/news'
import newsId from '@/views/news/_id'

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  routes: [
    {
      path: '/',
      component: index
    },
    {
      path: '/search',
      component: search
    },
    {
      path: '/exhibitions',
      component: exhibitions,
      meta: {
        keepAlive: true
      }
    },
    {
      path: '/exhibitions/create',
      component: exhibitionsCreate
    },
    {
      path: '/exhibitions/:id',
      component: exhibitionsId
    },
    {
      path: '/exhibitions/:id/publish',
      component: exhibitionsIdPublish
    },
    {
      path: '/news',
      component: news,
      meta: {
        keepAlive: true
      }
    },
    {
      path: '/news/:id',
      component: newsId
    }
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (about.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
    // }
  ],
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})
